{{--<style>
    .sticky-row {
        position: sticky;
        top: 0;
        left: 0;
        background: #f4f4f4;
    }

    /*表头*/
    table thead {
        z-index: 2;
        position: sticky;
        position: -webkit-sticky;
        top: 0;
        background: #f4f4f4;
    }
    table thead tr th:first-child{
        position: sticky;
        top: 0;
        left: 0;
        background: #f4f4f4;
    }
    th:nth-child(2){
        position: sticky;
        left: 4.9%;
        background: #f4f4f4;
    }
    th:nth-child(3){
        position: sticky;
        left: 9.6%;
        background: #f4f4f4;
    }
    th:nth-child(4){
        position: sticky;
        left: 12%;
        background: #f4f4f4;
    }
    th:nth-child(5){
        position: sticky;
        left: 14.7%;
        background: #f4f4f4;
    }
    th:nth-child(6){
        position: sticky;
        left: 18%;
        background: #f4f4f4;
    }

    /*表格*/
    table tbody tr td:first-child {
        z-index: 1;
        position: sticky;
        position: -webkit-sticky;
        left: 0;
        background: #f4f4f4;
    }
    td:nth-child(2){
        position: sticky;
        left: 4.9%;
        background: #f4f4f4;
    }
    td:nth-child(3){
        position: sticky;
        left: 9.6%;
        background: #f4f4f4;
    }
    td:nth-child(4){
        position: sticky;
        left: 12%;
        background: #f4f4f4;
    }
    td:nth-child(5){
        position: sticky;
        left: 14.7%;
        background: #f4f4f4;
    }
    td:nth-child(6){
        position: sticky;
        left: 18%;
        background: #f4f4f4;
    }
</style>--}}

<table class="table table-hover">
    <thead>
    <tr>
        @foreach($headers as $filed => $item)
        <th>{{ $item['title'] }}</th>
        @endforeach
    </tr>
    <tr style="color:#f56f9c">
        @foreach($headers as $filed => $item)
            @if($filed == 'report_date')
                <td class="sticky-row">TTL</td>
            @elseif($filed == 'profit_rate')
                <td>{{ floatval($total['sales_amount_rmb']) > 0 ? round($total['profit_rmb'] / $total['sales_amount_rmb'],5) * 100 .'%' : '0%' }}</td>
            @elseif($filed == 'total_rate')
                <td>{{ floatval($total['sales_amount_rmb']) > 0 ? round($total['earning_rmb'] / $total['sales_amount_rmb'],5) * 100 .'%' : '0%' }}</td>
            @elseif($item['sumField'])
                <td>{{ array_key_exists($filed,$total) ? $total[$filed] : '' }}</td>
            @else
                <td></td>
            @endif
        @endforeach
    </tr>
    </thead>
    <tbody>
    @foreach($paginator as $row)
        <tr>
            <td>{{ $row->report_date }}</td>
            <td>{{ $row->account->account ?? '' }}</td>
            <td>{{ $row->area->area ?? '' }}</td>
            <td>{{ $row->country->country ?? '' }}</td>
            <td>{{ \App\Util\User::getUsernameById($row->seller_id) }}</td>
            <td>{{ $row->sku->psku_code ?? '' }}</td>
            <td>{{ $row->sku->psku_cn ?? '' }}</td>
            <td>{{ $row->seller_sku ?: '' }}</td>
            <td>{{ $row->psku_id ? \App\Models\Product\ProductClassify::$_season[$row->sku->classify->season ?? 3] : ' ' }}</td>
            <td>{{ $row->sku->classify->title ?? '' }}</td>
            <td>{{ $row->rate_odds }}</td>
            <td>{{ $row->sales_volume }}</td>
            <td>{{ $row->sales_amount }}</td>
            <td>{{ $row->sales_amount_rmb }}</td>
            <td>{{ $row->selling_fees }}</td>
            <td>{{ $row->selling_fees_rmb }}</td>
            <td>{{ $row->fba_fees }}</td>
            <td>{{ $row->fba_fees_rmb }}</td>
            <td>{{ $row->refund_num }}</td>
            <td>{{ $row->refund_amount }}</td>
            <td>{{ $row->refund_amount_rmb }}</td>
            <td>{{ $row->p_thfba }}</td>
            <td>{{ $row->p_thfba_rmb }}</td>
            <td>{{ $row->purchase_price_rmb }}</td>
            <td>{{ $row->t_purchase_price_rmb }}</td>
            <td>{{ $row->shipment_price_rmb }}</td>
            <td>{{ $row->t_shipment_price_rmb }}</td>
            <td>{{ $row->ms_fee }}</td>
            <td>{{ $row->ms_fee_rmb }}</td>
            <td>{{ $row->lts_fee }}</td>
            <td>{{ $row->lts_fee_rmb }}</td>
            <td>{{ $row->p_icfee }}</td>
            <td>{{ $row->p_icfee_rmb }}</td>
            <td>{{ $row->rm_fee }}</td>
            <td>{{ $row->rm_fee_rmb }}</td>
            <td>{{ $row->rebates }}</td>
            <td>{{ $row->rebates_rmb }}</td>
            <td>{{ $row->spend }}</td>
            <td>{{ $row->spend_rmb }}</td>
            <td>{{ $row->reimburse_rmb }}</td>
            <td>{{ $row->reimburse_os_rmb }}</td>
            <td>{{ $row->reimburse_profit_rmb }}</td>
            <td>{{ $row->ied_rmb }}</td>
            <td>{{ $row->rod_rmb }}</td>
            <td>{{ $row->cplan_fee }}</td>
            <td>{{ $row->cplan_fee_rmb }}</td>
            <td>{{ $row->vat_fee }}</td>
            <td>{{ $row->vat_fee_rmb }}</td>
            <td>{{ $row->profit_rmb }}</td>
            <td>{{ getPercentage($row->profit_rmb,$row->sales_amount_rmb) }}</td>
            <td>{{ $row->earning_rmb }}</td>
            <td>{{ getPercentage($row->earning_rmb,$row->sales_amount_rmb) }}</td>
            <td>{{ $row->total }}</td>
            <td>{{ $row->total_rmb }}</td>
        </tr>
    @endforeach
    </tbody>
</table>
